package psn.hui.stat.utils;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;

public class ExportHSSFCellStyle {

	/**
	 * 创建基础样式 水平和垂直居中
	 * 
	 * @param workbook
	 * @return
	 */
	public static HSSFCellStyle createBaseCellStyle(HSSFWorkbook workbook) {
		HSSFCellStyle cellStyle = workbook.createCellStyle();
		// 水平居中
		cellStyle.setAlignment(HorizontalAlignment.CENTER);
		// 垂直剧中
		cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
		return cellStyle;
	}

	/**
	 * 创建数据表表头样式
	 */
	public static HSSFCellStyle createTableHeadCellStyle(HSSFWorkbook workbook) {
		// 获取水平和垂直居中样式
		HSSFCellStyle cellStyle = createBaseCellStyle(workbook);
		// 设置字体
		HSSFFont font = workbook.createFont();
		font.setBold(true);
		font.setFontHeightInPoints((short) 14);
		font.setColor(HSSFColor.HSSFColorPredefined.BLUE_GREY.getIndex());
		font.setFontName("黑体");
		cellStyle.setFont(font);
		return cellStyle;
	}

	/**
	 * 创建数据表小标题样式
	 */
	public static HSSFCellStyle createSubTitleCellStyle(HSSFWorkbook workbook) {
		// 获取水平和垂直居中样式
		HSSFCellStyle cellStyle = createBaseCellStyle(workbook);
		// 设置字体
		HSSFFont font = workbook.createFont();
		font.setBold(true);
		font.setFontHeightInPoints((short) 16);
		font.setColor(HSSFColor.HSSFColorPredefined.GREY_80_PERCENT.getIndex());
		font.setFontName("微软雅黑");
		cellStyle.setFont(font);
		return cellStyle;
	}

	/**
	 * 创建数据表标题样式
	 */
	public static HSSFCellStyle createTitleCellStyle(HSSFWorkbook workbook) {
		// 获取水平和垂直居中样式
		HSSFCellStyle cellStyle = createBaseCellStyle(workbook);
		// 设置字体
		HSSFFont font = workbook.createFont();
		font.setBold(true);
		font.setFontHeightInPoints((short) 20);
		font.setColor(HSSFColor.HSSFColorPredefined.DARK_BLUE.getIndex());
		font.setFontName("楷体");
		cellStyle.setFont(font);
		return cellStyle;
	}

	/**
	 * 创建数据行样式
	 */
	public static HSSFCellStyle createTableRowCellStyle(HSSFWorkbook workbook) {
		// 获取水平和垂直居中样式
		HSSFCellStyle cellStyle = createBaseCellStyle(workbook);
		// 设置字体
		HSSFFont font = workbook.createFont();
		font.setFontHeightInPoints((short) 12);
		font.setFontName("黑体");
		cellStyle.setFont(font);
		return cellStyle;
	}
}
